<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
		
<form:form commandName="sysMsg" cssClass="form-horizontal" role="form">
<%--	<div class="form-group">--%>
<%--		<label class="col-sm-2 control-label no-padding-right" for="msgId">信息ID</label>--%>
<%--		<div class="col-sm-4">--%>
<%--			<input type="text" name="userId" id="msgId" placeholder=1415  class="form-control required">--%>
<%--		</div>--%>

<%--		<label class="col-sm-2 control-label no-padding-right" for="chsName">简体名称</label>--%>
<%--		<div class="col-sm-4">--%>
<%--			<input type="text" name="chsName" id="chsName" placeholder="请输入简体名称" value="1" class="form-control required">--%>
<%--		</div>--%>
<%--	</div>--%>
<%--	<div class="form-group">--%>
<%--		<label class="col-sm-2 control-label no-padding-right" for="enName">英文名称</label>--%>
<%--		<div class="col-sm-4">--%>
<%--			<input type="text" name="enName" id="enName" placeholder="请输入英文名称"--%>
<%--				value="2222222" class="form-control required">--%>
<%--		</div>--%>
<%--		<label class="col-sm-2 control-label no-padding-right" for="chtName">繁体名称</label>--%>
<%--		<div class="col-sm-4">--%>
<%--			<input type="text" name="chtName" id="chtName" placeholder="请输入繁体名称" value="2" class="form-control required">--%>
<%--		</div>--%>
<%--		--%>
<%--	</div>--%>

	<div class="form-group">
		<div class="col-sm-12 row" id="Handle">
			<div class="information2 row">
				<div>
					<div id="Handles">
						<div class="form-group">
							<label class="col-sm-1 col-sm-offset-1 control-label">经办人</label>
							<div class="col-sm-9">
								<select name="taskUsers" multiple="true" id="e1" onchange="addHandle(this)">
									<option value="">请选择经办人</option>
								</select>
								<input type="hidden" value="">
							</div>
						</div>
					</div>
				</div>
<%--				<div class="row">--%>
<%--					<div class="col-sm-offset-3 col-sm-1">--%>
<%--						<button class="btn btn-info btn-sm" onclick="ApprovalConfirm(this)">确定</button>--%>
<%--					</div>--%>
<%--					<div class="col-sm-offset-4 col-sm-1">--%>
<%--						<button class="btn btn-info btn-sm" onclick="Handleremove();">取消</button>--%>
<%--					</div>--%>
<%--				</div>--%>
			</div>
		</div>



	</div>
	<form:hidden path="ids"/>
</form:form>

<script type="text/javascript">
	$.get("/tasklist/endorseList", function (data) {
		console.log(data)
		var option = "<option></option>"
		for (var i = 0; i < data.data.length; i++) {
			option += " <option value=" + data.data[i].sysId + ">" + data.data[i].name + "</option>"
		}
		$("#e1").html(option);
	})

	function addHandle(data) {
		$(data).siblings("input").val($(data).val().join(","));
	}

</script>
<script>

	$(document).ready(function () {
		$("#e1").select2({
			placeholder: "请输入或点击选择经办人",
			width: "100%",
			closeOnSelect: false,
			allowClear: true,
		});
	});
</script>
<script>
	function ApprovalConfirm(e) {
		failure($(e), 1)
		var taskUsers = $("#e1").siblings("input").val();
		if (taskUsers == null || taskUsers == "") {
			return alert("请选择经办人");
		}
		var taskSubId = $("#taskSubId").val();
		var sysId = $("#sysId").val();


		var datas = {
			sysId: sysId,
			taskSubId: taskSubId,
			taskUsers: taskUsers,

		};
		$.post("/taskUnit/saveTaskUser", datas, function (data) {
			if (data.code == 200) {
				failure($(e), 0)
				alert(data.message);
				setTimeout(function () {
					//刷新当前页面
					open(location, '_self').close();
				}, 50)
			} else {
				alert(data.message);
			}
		})
	}
</script>
